package com.starblink.android.basic.modules.mine

import android.content.Context
import com.starblink.android.basic.extension.navigationTo
import com.starblink.android.basic.user.LoginCheckInterceptor
import com.starblink.android.basic.user.UserDataCenter
import com.starblink.basic.route.RoutePage

/**
 * 管理我的相关内容，包括接口调用、页面跳转等
 */
object MineManager {
    const val KEY_PAGE_TYPE = "KEY_PAGE_TYPE"
    const val KEY_TAB_TYPE = "KEY_TAB_TYPE"
    const val KEY_USER_ID = "userId"
    const val KEY_ACCOUNT_DELETED = "KEY_ACCOUNT_DELETED"
    const val KEY_USERNAME = "KEY_USERNAME"
    const val KEY_ACCOUNT = "KEY_ACCOUNT"
    const val KEY_AVAILABLE = "KEY_IS_AVAILABLE"

    object PersonHomePageType {
        const val MINE = 0 //我的个人首页
        const val OTHER_USER = 1 //其他用户个人首页
    }

    object FollowPageTabType {
        const val TAB_FOLLOWING = 0 //我关注的用户
        const val TAB_FOLLOWERS = 1 //我的粉丝，关注了我的用户
    }

    /**
     * 跳转到我的关注页面
     * @param pageType
     */
    fun navigationToMineFollow(context: Context, tabType: Int) {
//        LoginCheckInterceptor.check2Login(context) {
            context.navigationTo(RoutePage.Mine.FOLLOW) {
                withInt(KEY_PAGE_TYPE, PersonHomePageType.MINE)
                withInt(KEY_TAB_TYPE, tabType)
            }
//        }
    }

    /**
     * 跳转到我的个人首页
     * @param pageType
     */
    fun navigationToMinePersonHome(context: Context) {
        //LoginCheckInterceptor.check2Login(context) {
            context.navigationTo(RoutePage.Mine.PERSON_HOME) {
                withInt(KEY_PAGE_TYPE, PersonHomePageType.MINE)
            }
        //}
    }

    /**
     * 跳转到其他用户个人首页（客态）
     * @param accountId 用户ID
     * @param accountDeleted 用户是否已删除
     */
    fun navigationToOtherUserPersonHome(
        context: Context,
        accountId: String,
        accountDeleted: Boolean?,
        userName: String? = null
    ) {
        //LoginCheckInterceptor.check2Login(context) {
            context.navigationTo(RoutePage.Mine.PERSON_HOME) {
                withInt(KEY_PAGE_TYPE, PersonHomePageType.OTHER_USER)
                withString(KEY_USER_ID, accountId)
                withBoolean(KEY_ACCOUNT_DELETED, accountDeleted ?: false)
                userName?.apply { withString(KEY_USERNAME, userName) }
            }
        //}
    }
}